<template>
    <a-modal
        :title="title"
        :width="width"
        :visible="visible"
        :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
        @ok="handleOk"
        @cancel="handleCancel"
    >
        <UserPositionForm ref="UserPositionForm" @ok="ok" :editable="editable" :canDismiss="canDismiss" :dataId="dataId" v-model="formData"></UserPositionForm>
    </a-modal>
</template>

<script>
import UserPositionForm from './UserPositionForm'
export default {
    name:'UserPositionModal',
    components:{
        UserPositionForm
    },
    data(){
        return {
            title:'',
            width:800,
            visible: false,
            disableSubmit: false,
            canDismiss:false,
            editable:true,
            formData:{},
            workflowModel:{
                operation: "start"
            },
            dataId:'',
            successTxt:''
        }
    },
    methods:{
        add (data) {
            this.edit(Object.assign({},data))
        },
        create(){
            this.edit()
        },
        edit (record,successTxt) {
            this.successTxt = successTxt||'编辑成功'
            this.visible=true
            this.formData = Object.assign({},record)
        },
        review (record) {
            record = Object.assign({},record)
            this.title = '查看'
            this.visible=true
            this.editable = false
            this.dataId =record.id
            // this.formData = record
            this.disableSubmit = true
        },
        close () {
            this.$emit('close');
            this.title = ''
            this.editable = true
            this.formData = {}
            this.disableSubmit = false
            this.visible = false;
        },
        handleOk () {
            this.$refs.UserPositionForm.submitForm()
        },
        handleCancel () {
            this.close()
        },
        ok(){
            this.visible = false
            this.formData = {}
            this.$emit('ok')
        }
    }
}
</script>

<style>

</style>